package com.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.system.mapper.TS_POSTPRICE_HEADMapper;
import com.system.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TS_POSTPRICE_HEADController {
    @Autowired
    private TS_POSTPRICE_HEADMapper tsPostpriceHeadMapper;

    @RequestMapping("deleteshanghubaijia")
    @ResponseBody
    public String deleteshanghubaijia(@RequestBody String s) {
        JSONObject object = new JSONObject();
        try {
            System.out.println("输入 : " + s);//接受前端参数
            s = s.replace("[", "");
            s = s.replace("]", "");

            JSONObject jsonobject = JSONObject.parseObject(s);
            System.out.println(jsonobject);
            String aDDRESS = jsonobject.getString("aDDRESS");
            System.out.println(aDDRESS);
            tsPostpriceHeadMapper.deleteBuyer(aDDRESS);

            object.put("code", 0);
            object.put("msg", "");
            return object.toJSONString();

        } catch (Exception e) {
            e.printStackTrace();
            return object.toJSONString();
        }
    }

    //显示
    @RequestMapping("selectPingZheng1")
    @ResponseBody
    public String selectPingZheng1() {
        String json = null;

        JSONObject object = new JSONObject();
        try {
            System.out.println("执行查询语句");
            //查询数据库
            //System.out.println(pl);
            List<Order> order = tsPostpriceHeadMapper.selectbuyerDOC();
            System.out.println(order);
            /* List<TS_SALEPLAN_LINE> list = tsPostpriceHeadMapper.selectListLimt2(pl, limit);*/
            for (Order attribute : order) {
             /*   String ID = attribute.getPLANORDERNO();//计划单据号
                String date = tsPostpriceHeadMapper.selectdate(ID);//最终时间
                String count = tsPostpriceHeadMapper.selectcount(ID); //已报价数量
                List<TS_SALEPLAN_LINE> max = tsPostpriceHeadMapper.selectMax(ID);//最高价
                for(TS_SALEPLAN_LINE max1 : max){
                    String max2=tsPostpriceHeadMapper.selectmax2(max1.getID());
                    System.out.println(max2);

                }*/

                object.put("code", 0);
                object.put("msg", "");
                object.put("data", order);
                json = object.toJSONString();
                System.out.println(json);
                return json;
            }


        } catch (Exception e) {
            e.printStackTrace();
            return json;

        }


        return json;
    }
}